package com.ruoyi.api.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SpBp2;
import com.ruoyi.system.service.ISpBp2Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 编排2Controller
 * 
 * @author ruoyi
 * @date 2022-11-12
 */
@RestController
@RequestMapping("/api/bp2")
public class SpBp2ApiController extends BaseController
{
    @Autowired
    private ISpBp2Service spBp2Service;

    /**
     * 查询编排2列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SpBp2 spBp2)
    {
        startPage();
        List<SpBp2> list = spBp2Service.selectSpBp2ListWeb(spBp2);
        return getDataTable(list);
    }

    /**
     * 导出编排2列表
     */
    @Log(title = "编排2", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SpBp2 spBp2)
    {
        List<SpBp2> list = spBp2Service.selectSpBp2ListWeb(spBp2);
        ExcelUtil<SpBp2> util = new ExcelUtil<SpBp2>(SpBp2.class);
        util.exportExcel(response, list, "编排2数据");
    }

    /**
     * 获取编排2详细信息
     */
    @GetMapping(value = "/{cj2Id}")
    public AjaxResult getInfo(@PathVariable("cj2Id") Long cj2Id)
    {
        return AjaxResult.success(spBp2Service.selectSpBp2ByCj2Id(cj2Id));
    }

    /**
     * 新增编排2
     */
    @Log(title = "编排2", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SpBp2 spBp2)
    {
        return toAjax(spBp2Service.insertSpBp2(spBp2));
    }

    /**
     * 修改编排2
     */
    @Log(title = "编排2", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SpBp2 spBp2)
    {
        return toAjax(spBp2Service.updateSpBp2(spBp2));
    }

    /**
     * 删除编排2
     */
    @Log(title = "编排2", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cj2Ids}")
    public AjaxResult remove(@PathVariable Long[] cj2Ids)
    {
        return toAjax(spBp2Service.deleteSpBp2ByCj2Ids(cj2Ids));
    }
}
